const USER_INFO = 'shop_user_info'

// 获取用户信息
export const getInfo = () => {
  const res = localStorage.getItem(USER_INFO)
  return res ? JSON.parse(res) : { userId: '', token: '' }
}

// 设置用户信息
export const setInfo = (data) => {
  localStorage.setItem(USER_INFO, JSON.stringify(data))
}

// 移除用户信息
export const removeInfo = () => {
  localStorage.removeItem(USER_INFO)
}

const HISTORY_KEY = 'shop_history_key'

export const getHistoryKeys = () => {
  const keys = localStorage.getItem(HISTORY_KEY)
  return keys ? JSON.parse(keys) : []
}

export const setHistoryKeys = (arr) => {
  localStorage.setItem(HISTORY_KEY, JSON.stringify(arr))
}
